<?php

/**
 * This is the model class for table "tbl_contents".
 *
 * The followings are the available columns in table 'tbl_contents':
 * @property integer $seq_no
 * @property string $title
 * @property string $comn_code
 * @property string $content_dtl
 * @property string $content_eng_dtl
 * @property string $use_yn
 * @property integer $sort_order
 * @property string $first_reg_user_id
 * @property string $first_reg_user_ip
 * @property string $first_reg_date
 * @property string $last_udp_user_id
 * @property string $last_udp_user_ip
 * @property string $last_udp_date
 *
 * The followings are the available model relations:
 * @property TblComnCode $comnCode
 */
class CContents extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'tbl_contents';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('title, comn_code, content_dtl, content_eng_dtl, use_yn, sort_order, first_reg_user_id, first_reg_user_ip, first_reg_date, last_udp_user_id, last_udp_user_ip, last_udp_date', 'required'),
			array('sort_order', 'numerical', 'integerOnly'=>true),
			array('title, comn_code, first_reg_user_id, first_reg_user_ip, last_udp_user_id, last_udp_user_ip', 'length', 'max'=>50),
			array('use_yn', 'length', 'max'=>1),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('seq_no, title, comn_code, content_dtl, content_eng_dtl, use_yn, sort_order, first_reg_user_id, first_reg_user_ip, first_reg_date, last_udp_user_id, last_udp_user_ip, last_udp_date', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'comnCode' => array(self::BELONGS_TO, 'TblComnCode', 'comn_code'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'seq_no' => 'Seq No',
			'title' => 'Title',
			'comn_code' => 'Comn Code',
			'content_dtl' => 'Content Dtl',
			'content_eng_dtl' => 'Content Eng Dtl',
			'use_yn' => 'Use Yn',
			'sort_order' => 'Sort Order',
			'first_reg_user_id' => 'First Reg User',
			'first_reg_user_ip' => 'First Reg User Ip',
			'first_reg_date' => 'First Reg Date',
			'last_udp_user_id' => 'Last Udp User',
			'last_udp_user_ip' => 'Last Udp User Ip',
			'last_udp_date' => 'Last Udp Date',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('seq_no',$this->seq_no);
		$criteria->compare('title',$this->title,true);
		$criteria->compare('comn_code',$this->comn_code,true);
		$criteria->compare('content_dtl',$this->content_dtl,true);
		$criteria->compare('content_eng_dtl',$this->content_eng_dtl,true);
		$criteria->compare('use_yn',$this->use_yn,true);
		$criteria->compare('sort_order',$this->sort_order);
		$criteria->compare('first_reg_user_id',$this->first_reg_user_id,true);
		$criteria->compare('first_reg_user_ip',$this->first_reg_user_ip,true);
		$criteria->compare('first_reg_date',$this->first_reg_date,true);
		$criteria->compare('last_udp_user_id',$this->last_udp_user_id,true);
		$criteria->compare('last_udp_user_ip',$this->last_udp_user_ip,true);
		$criteria->compare('last_udp_date',$this->last_udp_date,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return CContents the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
